package com.lollipop.rabbitmq.two;

import com.lollipop.rabbitmq.util.RabbitMqUtiils;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Author: Lollipop
 * @Date: 2021-10-03 13:24
 * @Description: 消费
 */
public class Worker01 {
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws IOException, TimeoutException {
        System.out.println("H");
        Channel channel = RabbitMqUtiils.getChannel();
        channel.basicConsume(QUEUE_NAME, true, (consumerTag, message) -> System.out.println("接收到的消息：" + new String(message.getBody())),
                consumerTag -> System.out.println("消息被中断"));
    }
}
